var express = require('express');
var router = express.Router();

const {
  login,
  verify,
  captcha,
  vcaptcha,
  findUsersList,
  insert,
  updateuser,
  delById,
  findById,
  editpwd
} = require("../controller/users");
const { authFilter } = require("../middlewares/auth");

class UsersRouter {
  static initRouter() {
    router.post('/login', login); // 登录
    router.get('/verify', verify);
    router.get('/captcha', captcha);
    router.get('/captcha/:vcode', vcaptcha);
    router.get('/', authFilter, findUsersList); // 获取所有用户信息
    router.post('/insert', authFilter, insert); // 新增用户
    router.get('/:id', authFilter, findById); // 获取单个用户信息
    router.put('/editpwd/:id', authFilter, editpwd); // 修改密码
    router.put('/:id', authFilter, updateuser); // 修改用户信息
    router.delete('/:id', authFilter, delById); // 删除用户
    return router;
  }
}
module.exports = UsersRouter.initRouter();